#include <algorithm>
#include <iostream>
#include <iterator>
#include <memory>
using namespace std;
#include <vector>
#include <ostream>
#include <list>

template <typename Container>
void populateContainer(Container& cont)
{
    while(true) {
        cout << "Enter a number (0 to quit), DONT PUT ANY CHAR: ";
        int value;
        cin >> value;
        if (value == 0) break;
        cont.push_back(value);
    }
}

int main()
{
    vector<int> myvec;
    list<int> mylist;

    cout << "populate the vector: " << endl;
    populateContainer(myvec);
    cout << "populate the list: " << endl;
    populateContainer(mylist);

    if (equal(cbegin(myvec), cend(myvec), cbegin(mylist), cend(mylist))) {
        cout << "the two containers have equal elements" << endl;
    } else {
        auto miss {mismatch(cbegin(myvec), cend(myvec), cbegin(mylist), cend(mylist))};
        cout << "the following initial elements are the same in "
        << "the vector and the list: " << endl;

        for (auto i {cbegin(myvec)}; i != miss.first; ++i) {
            cout << *i << '\t';
        }

        cout << endl;
    }

    if (lexicographical_compare(cbegin(myvec), cend(myvec), cbegin(mylist), cend(mylist))) {
        cout << "the vector is lexicographically first." << endl;
    } else {
        cout << "the list is lexicographically first." << endl;
    }


    return 0;
}